package com.atguigu.yygh.user.controller.user;


import com.atguigu.yygh.model.user.UserInfo;
import com.atguigu.yygh.result.R;
import com.atguigu.yygh.user.service.UserInfoService;
import com.atguigu.yygh.vo.user.LoginVo;
import com.atguigu.yygh.vo.user.UserAuthVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2025-03-19
 */
@Api(tags = "用户登录接口")
@RestController
@RequestMapping("/api/userinfo")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation("会员登录")
    @PostMapping("/login")
    public R login(@RequestBody LoginVo loginVo){
        Map<String,Object> info=userInfoService.login(loginVo);
        return R.ok().data(info);
    }
    @GetMapping("/getUserInfo")
    public R getUserInfo(@RequestHeader String token){
        //根据token获取用户信息
        UserInfo userInfo =userInfoService.getUserInfo(token);
        return R.ok().data("userInfo",userInfo);
    }
    @ApiOperation("用户实名认证")
    @PutMapping("auth/userAuth")
    public R userAuth(UserAuthVo userAuthVo, @RequestHeader String token){
        userInfoService.userAuth(userAuthVo,token);
        return R.ok();
    }

}

